package org.quickjsf.core.base.viewmodel.vo;

import java.io.Serializable;

public class FieldFilter implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 7052707127736772160L;

	private String field;
	
	private Object value;
	
	private Object otherValue; 
	
	private String valueCls;
	
	private Byte condition;
	
	private String convertValue;
	
	
//	private Byte joinLogic;
	
	public FieldFilter() {
		//default value
		this.field = "all";
		this.condition = CondType.ALL_COND;
	}

	public FieldFilter(String field, Object value, Byte condition) {
		super();
		this.field = field;
		this.value = value;
		this.condition = condition;
	}

	public String getField() {
		return field;
	}

	public void setField(String field) {
		this.field = field;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	public Object getOtherValue() {
		return otherValue;
	}

	public void setOtherValue(Object otherValue) {
		this.otherValue = otherValue;
	}

	public Byte getCondition() {
		return condition;
	}

	public void setCondition(Byte condition) {
		this.condition = condition;
	}

	public String getValueCls() {
		return valueCls;
	}

	public void setValueCls(String valueCls) {
		this.valueCls = valueCls;
	}
	
	public static final String FIELD_SPLIT = "-";
	
	public static final class CondType{
		public static final byte ALL_COND = -0x0;
		public static final byte EQ = 0x1;
		public static final byte LE = 0x2;
		public static final byte GT = 0x3;
		public static final byte BETWEEN = 0x4;
		public static final byte LIKE = 0x5;
	}
	public static final class CondTypeName{
		public static final String EQ = "等于";
		public static final String LE = "小于";
		public static final String GT = "大于";
		public static final String BETWEEN = "介于";
		public static final String LIKE = "包含";
	}
	
	public static String getConditionName(byte type) {
		switch (type) {
		case CondType.EQ:
			return CondTypeName.EQ;
		case CondType.LE:
			return CondTypeName.LE;
		case CondType.GT:
			return CondTypeName.GT;
		case CondType.BETWEEN:
			return CondTypeName.BETWEEN;		
		case CondType.LIKE:
			return CondTypeName.LIKE;				
		default:
			break;
		}
		return "";
	}

	public String getConvertValue() {
		return convertValue;
	}

	public void setConvertValue(String convertValue) {
		this.convertValue = convertValue;
	}
}
